package Unite;

public abstract class Unit {
	
	final static public int ARCHER = 0;
	final static public int GUERRIER = 1;
	final static public int CHEVALIER = 2;
	final static public int TORUK = 3;
	final static public int MAX_UNIT = 4;

	final static private double WEIGHT_RATIO = 1;
	final static private double POWER_RATIO = 1;

	final static private Integer CLASSE = null;

	private static int _idCount = 0;
	protected int _id;
	protected AttributeMap _attributes;
	protected int _level;
	protected double _weight;
	protected double _power;

	/**
	 * @param id
	 * @param attributes
	 * @param level
	 */
	public Unit(AttributeMap attributes, int level) {
		_id = _idCount;
		_idCount++;
		setAttributes(attributes);
		setLevel(level);
		_weight = calculateWeight();
		_power = calculatePower();
	}

	/**
	 * @param level
	 */
	public void setLevel(int level) {
		if (level > 0)
			_level = level;
		else
			_level = 1;
	}

	/**
	 * @return
	 */
	private int calculateWeight() {
		return _attributes.getWeight();
	}

	/**
	 * @return
	 */
	private double calculatePower() {
		return 1;
	}

	/**
	 * @return
	 */
	public int getId() {
		return _id;
	}

	/**
	 * @return
	 */
	public AttributeMap getAttributes() {
		return _attributes;
	}

	/**
	 * @param attributes
	 */
	public void setAttributes(AttributeMap attributes) {
		_attributes = attributes;
	}

	/**
	 * @return
	 */
	public double getWeight() {
		return _weight * WEIGHT_RATIO / 10;
	}

	/**
	 * @return
	 */
	public int getLevel() {
		return _level;
	}

	/**
	 * @param u
	 * @return
	 */
	public double getPower() {
		return _power * POWER_RATIO / 10;
	}

	public double getOffense(Unit unitOpponent) {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * @return
	 */
	public int getClasseId() {
		return CLASSE;
	}

	/**
	 * @return
	 */
	public Unit getCopy() {
		return null;
	}

}
